<?php
$name = trim($_POST['eventname']);
$icon = $_POST['icon'];

if (!empty($img)){
    $img = $_POST['img'];
}else{
    $img = 0;
}

include_once 'connect.php';
$charu = "insert into lovelist (eventname,icon,imgurl) values ('$name','$icon','$img')";
$result = mysqli_query($connect,$charu);
if ($result) {
    echo "<script>alert('事件新增成功');location.href = '/admin/lovelist.php';</script>";
} else {
    echo "'<script>alert('事件新增失败$name');history.back();</script>";
//    echo "$qq,$name,$text,$time";
}